package task3;

/**
 * 手机卡类
 */
public class PhoneCard {
    // 卡类型
    private PhoneCardType types;
    // 卡号
    private String id;
    // 用户名
    private String username;
    // 密码
    private String password;
    // 账户余额
    private double balance;
    // 通话时长
    private double time;
    // 上网流量
    private double data;
    // 通话套餐
    private PhonePackage phonePackage;
    // 上网套餐
    private NetPackage netPackage;
    // 卡的消费信息
    private UserConsume userConsume;

    // 无参构造
    public PhoneCard() {
    }

    // 有参构造
    public PhoneCard(PhoneCardType types, String id, String username, String password, double balance, double time, double data) {
        this.types = types;
        this.id = id;
        this.username = username;
        this.password = password;
        this.balance = balance;
        this.time = time;
        this.data = data;
    }

    public PhoneCardType getTypes() {
        return types;
    }

    public void setTypes(PhoneCardType types) {
        this.types = types;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getTime() {
        return time;
    }

    public void setTime(double time) {
        this.time = time;
    }

    public double getData() {
        return data;
    }

    public void setData(double data) {
        this.data = data;
    }

    public PhonePackage getPhonePackage() {
        return phonePackage;
    }

    public void setPhonePackage(PhonePackage phonePackage) {
        this.phonePackage = phonePackage;
    }

    public NetPackage getNetPackage() {
        return netPackage;
    }

    public void setNetPackage(NetPackage netPackage) {
        this.netPackage = netPackage;
    }

    public UserConsume getUserConsume() {
        return userConsume;
    }

    public void setUserConsume(UserConsume userConsume) {
        this.userConsume = userConsume;
    }

    // 显示卡号、用户名、当前余额、套餐情况
    public void show(){
        System.out.println("卡号："+ this.getId() + "  用户名：" + this.getUsername() + "  当前余额：" + this.getBalance());
        // 若无通话套餐
        if (this.getPhonePackage() == null){
            System.out.print("当前电话卡无通话套餐！");
        }
        // 若有通话套餐
        else{
            // 直接显示该卡通话套餐信息
            this.getPhonePackage().show();
        }
        // 若无上网套餐
        if (this.getNetPackage() == null){
            System.out.println("当前电话卡无上网套餐！");
        }
        // 若有上网套餐
        else{
            // 直接显示该卡流量套餐信息
            this.getNetPackage().show();
        }
    }
}
